add id jquery

57

add id jquery -

$('element').attr('id', 'value');

how to add id in jquery -

var $newdiv1 = $( "<div id='object1'></div>" ),
  newdiv2 = document.createElement( "div" ),
  existingdiv1 = document.getElementById( "foo" );
 
$( "body" ).append( $newdiv1, [ newdiv2, existingdiv1 ] );

how to add id in jquery -

$( "li" ).add( "<p id='new'>new paragraph</p>" )
  .css( "background-color", "red" );

how to add id in jquery -

var pdiv = $( "p" );
pdiv.add( "div" ); // WRONG, pdiv will not change

how to add id in jquery -

$( "li" ).add( document.getElementsByTagName( "p" )[ 0 ] )
  .css( "background-color", "red" );

how to add id in jquery -

$( "li" ).add( "p" ).css( "background-color", "red" );

Comments

Submit
0 Comments